// Sample
// Copyright 2006
#include "sample_wrap/sample.h"

// Calls int div (int a, int b)
dObject *dDiv (dList *args)
{
  dNumber *temp; // dNumber to return
  if (args == 0)
    return new dError("div: requires 2 arguments");

  dNumber *a;
  if ((*args)[0]->type != 'i')
    return new dError ("div: argument 1 must be an integer");
  a = (dNumber*)(*args)[0];

  dNumber *b;
  if ((*args)[1]->type != 'i')
    return new dError ("div: argument 2 must be an integer");
  b = (dNumber*)(*args)[1];
  temp = new dNumber (div (toInt (a), toInt (b)));
  return temp;
}

// Calls int mod (int a, int b)
dObject *dMod (dList *args)
{
  dNumber *temp; // dNumber to return
  if (args == 0)
    return new dError("mod: requires 2 arguments");

  dNumber *a;
  if ((*args)[0]->type != 'i')
    return new dError ("mod: argument 1 must be an integer");
  a = (dNumber*)(*args)[0];

  dNumber *b;
  if ((*args)[1]->type != 'i')
    return new dError ("mod: argument 2 must be an integer");
  b = (dNumber*)(*args)[1];
  temp = new dNumber (mod (toInt (a), toInt (b)));
  return temp;
}


extern "C"
void
load_module ()
{
  addToSystem ("div", dDiv);
  addToSystem ("mod", dMod);
}
